package com.example.demo.view

import android.content.Context
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.unit.ExperimentalUnitApi
import androidx.lifecycle.viewmodel.compose.viewModel
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.rememberNavController
import com.example.demo.buildNestedNavigationGraph
import com.example.featuresdk.viewmodel.NavigationViewModel

@ExperimentalUnitApi
@ExperimentalFoundationApi
@Composable
fun AppNavigationView(navigationViewModel: NavigationViewModel = viewModel(), context: Context){

    val navController = rememberNavController()

    //initialize information to be shared across all screens
    navigationViewModel.screenWithDp = LocalConfiguration.current.screenWidthDp
    navigationViewModel.screenHeightDp = LocalConfiguration.current.screenHeightDp
    navigationViewModel.navHostController = navController

    //full screen mode
//    Column(Modifier.fillMaxSize()) {
//
//        AppHeaderFeatureView(navigationViewModel,navController)
//
//        AppNavigationGraph(navigationViewModel,navController)
//
//        AppBottomNavigationView(navigationViewModel, navController)
//    }
      AppNavigationGraph(navigationViewModel)

//        AnimatedVisibility(
//            visible = navigationViewModel.showHeaderFooterScreenMode.value,
//            enter = fadeIn(
//                // Overwrites the initial value of alpha to 0.4f for fade in, 0 by default
//                initialAlpha = 0.4f
//            ),
//            exit = fadeOut(
//                // Overwrites the default animation with tween
//                animationSpec = tween(durationMillis = 250)
//            )
//        ) {
//            Text("Hellp ****")
//        }
//        Button(onClick = { navigationViewModel.showHeaderFooterScreenMode.value = !navigationViewModel.showHeaderFooterScreenMode.value })
//        { Text("Toggle") }
}

//construct the navigation graph with starting destination as the first primary feature
@ExperimentalUnitApi
@ExperimentalFoundationApi
@Composable
fun AppNavigationGraph(navigationViewModel: NavigationViewModel){

//    Log.i("AppNavigationGraph", "****${navigationViewModel.homeFeatureKey.value}")

    NavHost(navController = navigationViewModel.navHostController, startDestination = "${navigationViewModel.homeFeatureKey.value}") {
        buildNestedNavigationGraph(navigationViewModel)
    }
}